package game;

import javax.microedition.khronos.opengles.GL10;

import android.graphics.PointF;

import gfx.Camera;
import gfx.Image;
import util.GameVars;
import util.InteractableInterface;
import util.Logger;

public class SplashScreen implements InteractableInterface{
	Image splashImage;

	private boolean next;
	private boolean isLoaded = false;
//	private boolean isReady;
	
	public SplashScreen(){
		load();
	}
	
	public void load(){
		next = false;
		splashImage = new Image(GameVars.TEXTURE_SPLASH_BACKGROUND, Camera.GL_WIDTH, Camera.GL_HEIGHT);
//		isLoaded = true;
	}
	
	public void update(long time){
	}
	
	// TODO Figure out why this is the only fix :x
	public void draw(GL10 gl){
		splashImage = new Image(GameVars.TEXTURE_SPLASH_BACKGROUND, Camera.GL_WIDTH, Camera.GL_HEIGHT);
		gl.glPushMatrix();
		
		gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
		gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
		
		gl.glTranslatef(Camera.GL_WIDTH * .5f, Camera.GL_HEIGHT * .5f, 0);
		splashImage.draw(gl);  
		
		gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST);
		gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_NEAREST);
		
		gl.glPopMatrix();
		
//		isReady = true;
	}
	
	public boolean next(){ return next; }
//	public boolean isReady(){ return isReady; }
	public boolean isLoaded() {return isLoaded; }

	@Override
	public void buttonHandler(int num) {			
	}

	@Override
	public void handleUp(PointF location) {
		next = true;
	}

	@Override
	public void handleDrag(PointF location) {			
	}

	@Override
	public void handleTouch(PointF location) {			
	}
	
	public boolean handleBackPress(){
		return false;
	}
}
